<?php

// Aug 29, 2010: immanuel192 write this controller

if (!defined('EXPONENT')) exit('');

$tag = null;
if (isset($_POST['id'])) {
	$tag = $db->selectObject('cufonmodule_items','id='.intval($_POST['id']));
	if ($tag) {
		$loc = unserialize($tag->location_data);
	}
}

if (($tag && exponent_permissions_check('administrate',$loc)) || (!$tag && exponent_permissions_check('administrate',$loc))) {
	$tag = cufon_item::update($_POST,$tag);
	$tag->location_data = serialize($loc);

	if (isset($tag->id)) {
		$db->updateObject($tag,'cufonmodule_items');
	} else {
		$db->insertObject($tag,'cufonmodule_items');
	}
	exponent_flow_redirect();
} else {
	echo SITE_404_HTML;
}

?>
